<template>
	<view class="header-bg-image header-bg">
		<view style="height: 50rpx;"></view>
		<view class="padding-30">
			<view class="margin-30-0 flex-around" @click="$tools.navigateBack()">
				<u-icon name="arrow-left" color="#333333" size="20"></u-icon>
				<view class="fontSize-18 color-000 flex1 text-center">姓名</view>
				<view style="width: 40rpx;"></view>
			</view>
			<view class="margin-top150">
				<input class="input-name"  type="text" v-model="nickname" placeholder="请输入名称"/>
			</view>
			<view class="margin-top150">
				<view class="btn30-967C5E-15ffffff flex-center" @click="submitEvent">保存</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				nickname:''
			}
		},
		onShow() {
			this.getUserInfo()
		},
		methods:{
			// 获取个人信息
			async getUserInfo() {
				let res = await this.$http.post(this.$api.user_info, {}, {
					token: true
				})
				this.nickname = res.data.nickname
			},
			// 提交个人信息
			async submitEvent(){
				let form = {
					nickname: this.nickname
				}
				let res = await this.$http.post(this.$api.profile,form,{token:true})
				console.log(res)
				if(res.code ==1){
					this.$tools.toast('修改成功')
					this.$tools.navigateBack(1,200)
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.input-name {
		border: 2rpx solid #967C5E;
		padding: 30rpx;
		background-color: #ffffff;
		border-radius: 60rpx;
		font-size: 15px;
		color: #000000;
	}
</style>